package LEETCODE2023.BISHUA100;

public class SolutionBM84 {
    public static void main(String[] args) {
        String[] strs = new String[] {"abca","abc","abca","abc","abcc"};
        System.out.println(longestCommonPrefix(strs));
    }
    public static String longestCommonPrefix(String[] strs) {
        if (strs.length == 0) {
            return "";
        }
        for (int j = 0; j < strs[0].length(); j++) {
            char tag = strs[0].charAt(j);
            for (int i = 1; i < strs.length; i++) {
                if (j==strs[i].length()||strs[i].charAt(j)!=tag){
                    return strs[0].substring(0,j);
                }
            }
        }
        return strs[0];
        // write code here
    }
}
